<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.prime.com.tr/ui">

    <ui:composition template="/template/DefaultTemplate.xhtml">

        <ui:define name="top">
            <title>Email</title>
        </ui:define>

        <ui:define name="left">
            left
        </ui:define>
        <ui:define name="content">
            <f:view contentType="text/html">
                <p:tabView effect="opacity" effectDuration="normal" dynamic="true" cache="false"
                           style="width:800px;height:980px"> 
                    <p:tab title="Order Detail" id ="create"> 

                        <h:form >

                            <p:panel header="Order Information.Click cell if you need to edit."> 
                                <h:panelGrid columns="2" columnClasses="column" cellpadding="5"> 
                                    <h:outputText value="Vendor:"/>
                                    <h:outputText value="#{rawMaterialPurchaseOrderEditController.selectedPurchaseOrder.rmq.vendor.companyName}"/>

                                    <h:outputText value="Product Name:"/>
                                    <h:outputText value="#{rawMaterialPurchaseOrderEditController.selectedPurchaseOrder.rmq.rawMaterial.productName}"/>     
                                    <h:outputText value="Unit Price(S$):"/>
                                    <p:inplace editor="true" > 

                                        <p:inputText value="#{rawMaterialPurchaseOrderEditController.price}"
                                                     required="true" label="text"/>  
                                    </p:inplace> 

                                    <h:outputText value="Quantity:"/>
                                    <p:inplace editor="true" > 

                                        <p:inputText value="#{rawMaterialPurchaseOrderEditController.quantity}"
                                                     required="true" label="text"/>  
                                    </p:inplace> 
                                    <h:outputText value="Figure Cost(S$):"/>
                                    <p:inplace editor="true" > 

                                        <p:inputText value="#{rawMaterialPurchaseOrderEditController.figureCost}"
                                                     required="true" label="text"/>  
                                    </p:inplace> 
                                    <h:outputText value="Total cost after adjustion(S$) :"/>
                                    <p:inplace editor="true" > 

                                        <p:inputText value="#{rawMaterialPurchaseOrderEditController.cost}"
                                                     required="true" label="text"/>  
                                    </p:inplace> 

                                    <h:outputText value="Vendor Note:"/>
                                    <h:outputText value="#{rawMaterialPurchaseOrderEditController.selectedPurchaseOrder.rmq.note}"/>              
                                    <h:outputText value="Order initiated by:"/>
                                    <h:outputText value="#{rawMaterialPurchaseOrderEditController.selectedPurchaseOrder.createdBy.name}"/>     
                                </h:panelGrid> 

                            </p:panel>  
                            <p:commandButton action="#{rawMaterialPurchaseOrderEditController.done}" ajax="false" value="Confirm change" update="growl"/>   

                            <p:commandButton action="#{rawMaterialPurchaseOrderEditController.confirm}" ajax="false" value="  Back"/>    

                        </h:form>
                    </p:tab>
                    <p:tab title="Delivery Schedule:" id ="cree"> 

                        <h:form prependId ="false" id="erView">

                            <p:panel header="Enter delivery Schedule for this order: " style="text-align: center">
                                <h:panelGrid columns="2" > 
                                    <h:outputText value="Usual lead time for this raw material:"/>
                                    <h:outputText value="#{rawMaterialPurchaseOrderEditController.selectedPurchaseOrder.rmq.rawMaterial.leadTime}&#160;weeks"/>

                                    <h:outputText value="Total shipping amount of this order:"/>
                                    <h:outputText value="#{rawMaterialPurchaseOrderEditController.selectedPurchaseOrder.quantity}"/>     
                                    <h:outputText value="Enter Shipping Amount:"/>
                                    <br/>

                                    <p:inputText value="#{rawMaterialPurchaseOrderEditController.amount}"/>
                                    <br/>

                                    <p:separator/>
                                    <br/>

                                    <h:outputText value="Date Received:"/>
                                    <br/>
                                    <p:calendar value="#{rawMaterialPurchaseOrderEditController.validity}" mode ="inline" mindate ="#{selectedPurchaseOrder.rmq.validity}"/>               
                                </h:panelGrid> 
                            </p:panel>
                            <p:commandButton actionListener="#{rawMaterialPurchaseOrderEditController.scheduleDelivery}"  value="Update Schedule Shipment" update="panel,books"/> 
<p:commandButton actionListener="#{rawMaterialPurchaseOrderEditController.resetSchedule}"  value="Reset" update="panel,books"/> 
                            <p:separator /> 

                            <p:panel header="Schedule Shipment:">
                                <p:outputPanel id="books">  
                                    <p:dataTable value="#{rawMaterialPurchaseOrderEditController.scheduleShip}" var="entry" >
                                        <p:column>
                                            <f:facet name="header" >
                                                <h:outputText value="Shipment date:"/>
                                            </f:facet>
                                            <p:dataTable value="#{entry}" var="type" >
                                                <p:column>

                                                    <h:outputText value="#{type.key}">
                                                        <f:convertDateTime pattern="dd/MM/yyyy" />
                                                    </h:outputText>

                                                </p:column>
                                            </p:dataTable>
                                        </p:column>
                                        <p:column>
                                            <f:facet name="header" >
                                                <h:outputText value="Amount:"/>
                                            </f:facet>
                                            <p:dataTable value="#{entry}" var="type" >
                                                <p:column>

                                                    <h:outputText value="#{type.value}"/>

                                                </p:column>
                                            </p:dataTable>
                                        </p:column>



                                    </p:dataTable>
                                </p:outputPanel>  
                            </p:panel>


                            <p:commandButton action="#{rawMaterialPurchaseOrderEditController.doneSchedule}" ajax="false" value="Confirm Change" update ="growl"/>
                        </h:form>
                    </p:tab>
                    <p:tab title="Payment Info:" id ="ee"> 

                        <h:form prependId ="false" id="eriew">

                            <p:panel header="Enter Payment Info for this order." style="text-align: center">
                                <h:panelGrid columns="2" columnClasses="column" cellpadding="5"> 
                                    <h:outputLabel value ="Payment to:" />
                                    <h:outputText value="#{rawMaterialPurchaseOrderEditController.selectedPurchaseOrder.rmq.vendor.companyName}" />
                                    <br />

                                    <h:outputText value="#{rawMaterialPurchaseOrderEditController.address.streetAddress}" />
                                    <br/>

                                    <h:outputText value="#{rawMaterialPurchaseOrderEditController.address.city}" />                
                                    <br/>
                                    <h:outputText value="#{rawMaterialPurchaseOrderEditController.address.stateOrProvice}"  />
                                    <br/>

                                    <h:outputText value="#{rawMaterialPurchaseOrderEditController.address.country}"  />
                                    <br/>
                                    <h:outputText value="#{rawMaterialPurchaseOrderEditController.address.zipCode}"  />
                                    <br />
                                    <p:separator style="width:400px;height:3px" />

                                    <h:outputText value="Post payment to bank account:"/>
                                    <p:inplace editor="true" > 

                                        <p:inputText value="#{rawMaterialPurchaseOrderEditController.bankAccount}"
                                                     required="true" label="text"/>  
                                    </p:inplace> 


                                </h:panelGrid>
                            </p:panel>
                            <p:commandButton action="#{rawMaterialPurchaseOrderEditController.payment}" ajax="false" value="Confirm change" update="growl"/>   

                        </h:form>
                    </p:tab>
                </p:tabView>
            </f:view>
        </ui:define>

    </ui:composition>

</html>